ACTOR DualPistols : BrutalWeapon
{
	Weapon.AmmoUse1 0
	Weapon.AmmoGive1 0
	Weapon.AmmoUse2 0
	Weapon.AmmoGive2 0
	Weapon.AmmoType1 "Clip1"
	Weapon.AmmoType2 "BDDualPistolAmmo"
	Weapon.PreferredSkin "Dual Pistol Marine"
	Obituary "%o was shot down by %k's pistol."
    AttackSound "None"
	weapon.selectionorder 5000
    Inventory.PickupSound "CLIPIN"
	Inventory.Pickupmessage "You got the Pistol! (Slot 2)"
    +WEAPON.NOAUTOAIM
    +WEAPON.NOAUTOFIRE
	+WEAPON.NO_AUTO_SWITCH
	+WEAPON.WIMPY_WEAPON
    +FORCEXYBILLBOARD
	Scale 0.9
	+WEAPON.NO_AUTO_SWITCH
	Tag "Dual Pistols"
	Inventory.ForbiddenTo Paladin, Corvus
	States
	{
	NoAmmoOnSecondGun:
		PI2G A 2
	Ready3:
	ReadyLoop:
		Ready:
	    TNT1 A 0
		TNT1 A 0 A_PlaySound("CLIPIN", 1)
		TNT1 A 0
		TNT1 A 0 A_TakeInventory("StopDualWield", 1)
		TNT1 A 0 A_PlaySound("CLIPIN", 3)
		TNT1 A 0 A_GunFlash
		Goto ReadyToFire

	SpellFlash:
		MPIR UUUUVVVVVVVVVVVVVVVVVVVVVUUU 1
		stop
	
	DualWield:
		PI2G A 1
		PI2G A 0 A_Takeinventory("StartDualWield",1)
		PI2G A 0 A_SelectWEapon("Schism_Pistol")
		Goto Ready	
		
	Deselect:
        PIS2 BA 1
		TNT1 AAAAAAAAAAAAAAAAAA 0 A_Lower
		PI2G A 0 A_TakeInventory("TossGrenade", 1)
		TNT1 A 1 A_Lower
		Wait
		
	Select:
		TNT1 A 1
		TNT1 A 1 A_Raise
		TNT1 AAAAAAAAAA 0 A_Raise
		Goto Ready
		
		
	SelectAnimation:
		TNT1 A 1
	    PI2G A 0 A_JumpIfInventory("GoFatality", 1, "Steady")
        PI2G A 0 A_PlaySound("CLIPIN")
        PI2S ABCD 1
		PI2G A 0 A_Takeinventory("StartDualWield",1)
        PI2G A 0 A_GunFlash
		Goto Ready

	AltFire:
		TNT1 A 0
		Goto ReadyToFire

	Fire:
	TNT1 A 0
	TNT1 A 0 A_JumpIfInventory("FiredPrimary",1,"FireLeftGun") //Check if player wants to reload
	PI2G I 1 //A_WeaponReady(WRF_NOFIRE)
	//TNT1 A 0 A_JumpIfInventory("FiredPrimary",1,"FireLeftGun") //Check if player wants to reload
	TNT1 A 0 A_Refire
	Goto ReadyToFire
	
	ReadyToFire:
		TNT1 A 0
		TNT1 A 0 A_SetCrosshair(0)
		TNT1 A 0 A_JumpIfInventory("FiredPrimary",1,"FireLeftGun") //Check if player wants to reload
		PI2G I 0
		PI2G I 0 A_JumpIfInventory("LeftPistolAmmo",1,2)
		PI2G H 0
		"####" "#" 1 A_WeaponReady// Weapon is ready to fire
	    PI2G A 0 A_JumpIfInventory("Kicking",1,"DoKick")
        PI2G A 0 A_JumpIfInventory("Taunting",1,"Taunt")
		PI2G A 0 A_JumpIfInventory("Salute1", 1, "Salute")
		PI2G A 0 A_JumpIfInventory("Salute2", 1, "Salute")
        PI2G A 0 A_JumpIfInventory("Reloading",1,"Reload")
		PI2G A 0 A_JumpIfInventory("Unloading",1,"Unload")
		PI2G A 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
		PI2G A 0 A_JumpIfInventory("StartDualWield",1,"DualWield")
		Loop
	
	FireLeftGun:
	    PI2G I 0
		TNT1 A 0 A_JumpIfInventory("BDDualPistolAmmo", 1, 1)//First of all, checks if there is ammo inside the gun
		Goto Reload//Couldn't find any ammo. Reload
		
		TNT1 A 0 A_JumpIfInventory("LeftPistolAmmo", 1, 1)//Checks if there is ammo inside the left Pistol
		Goto DryFire//Couldn't find any ammo. Don't fire.
		
		TNT1 A 0 A_TakeInventory("BDDualPistolAmmo", 1)//Removes 1 ammo from magazine
		//PI2G A 0 A_JumpIfInventory("BDDualPistolAmmo",1,1)
        //Goto NoAmmo
		//TNT1 A 0 A_JumpIFInventory("PistolBurstFire", 1, "Fire2")
		//PI2G A 0 A_JumpIfInventory("BDPistolAmmo",1,1)//Checks if single gun is not depleted
        //Goto NoAmmoOnSecondGun
		TNT1 A 0 A_AlertMonsters
		RIFF A 0 A_FireCustomMissile("DistantFireSoundShotgun", random(-1,1), 0, 0, -12, 0, random(-1,1))
        PI2G A 0 A_PlaySound("pfire", 1)
		PI2G A 0 A_ZoomFactor(0.98)
		PI2G A 0 A_FireCustomMissile("YellowFlareSpawn",0,0,0,0)
		PI2G F 1 BRIGHT A_FireBullets (4, 2, -1, 17, "WeakPuff", FBF_NORANDOM)
		PI2G A 0 A_ZoomFactor(1.0)
        RIFF A 0 A_FireCustomMissile("DecorativeTracer", -1, 0, -4, 1)
		//PI2G A 0 A_Takeinventory("BDDualPistolAmmo",1)
		//PI2G A 0 A_Takeinventory("BDPistolAmmo",1)
        PI2G G 1
		PI2G H 1 A_TakeInventory("LeftPistolAmmo", 1)//Remove the fake ammo
		TNT1 A 0 A_JumpIfInventory("BDDualPistolAmmo", 1, 1)//Checks if there is ammo inside the gun
		Goto Reload//Couldn't find any ammo. Reload.
		PI2G I 0 A_JumpIfInventory("LeftPistolAmmo", 1, 2)//sliding frame
		PI2G H 0
		PI2G "#" 1
		PI2G "#" 0 A_FireCustomMissile("PistolCaseSpawn",5,0,-10,-4)
		PI2G "#" 2 A_WeaponReady(WRF_NOBOB)
		//PI2G "#" 0 A_Refire
		PI2G "#" 0 A_JumpIfInventory("LeftPistolAmmo", 1, 1)//Checks if there is ammo inside the left Rifle
		Goto DryFire//Couldn't find any ammo. Don't fire.
		PI2G "#" 0 A_JumpIfInventory("FiredPrimary",1,"FireLeftGun") //Check if player still is firing left gun
		//PI2G "#" 0
		Goto ReadyToFire//No need to reload. Get back to Ready state.

		
		DryFire:
	    //PI2G I 0 A_PlaySound("DRYFIRE", 1)
		//PI2G I 10
		PI2G H 1
		Goto ReadyToFire
	
Flash:	
	    TNT1 A 0
		TNT1 A 0 A_JumpIfInventory("StopDualWield", 1, "LightDone")
		TNT1 A 0 A_JumpIfInventory("FiredSecondary", 1, "FireRightGun")
		PI2G E 0 A_JumpIfInventory("BDPistolAmmo",1,2)
		PI2G D 0
		"####" "#" 1
		TNT1 A 0 A_JumpIfInventory("TossGrenade", 1, "GoAway")
		TNT1 A 0 A_JumpIfInventory("StartDualWield",1,"GoAway")
		//P2W1 A 1
		Loop
	
		GoAway:
		TNT1 A -1
		Stop
	
	DontFlash:
	    PI2G D 1
		Goto Flash
	
    FireRightGun:
	    PI2G E 0
		
		TNT1 A 0 A_JumpIfInventory("StopDualWield", 1, "LightDone")
		TNT1 A 0 A_GiveInventory("IsFiringSecondary", 1)
		TNT1 A 0 A_JumpIfInventory("BDDualPistolAmmo", 1, 2)//First of all, checks if there is ammo inside the gun
		TNT1 A 0 //A_GiveInventory("Reloading", 1)//Couldn't find any ammo. Reload
		Goto DontFlash//Couldn't find any ammo. Reload
		
		TNT1 A 0 A_JumpIfInventory("BDPistolAmmo", 1, 1)//Checks if there is ammo inside the left Rifle
		Goto DryFire2//Couldn't find any ammo. Don't fire.
		
        PI2G A 0 A_JumpIfInventory("BDDualPistolAmmo",1,1)
        Goto NoAmmo
		//TNT1 A 0 A_JumpIFInventory("PistolBurstFire", 1, "Fire2")
		//PI2G A 0 A_JumpIfInventory("BDPistolAmmo",1,1)//Checks if single gun is not depleted
        //Goto NoAmmoOnSecondGun
		TNT1 A 0 A_AlertMonsters
		RIFF A 0 A_FireCustomMissile("DistantFireSoundShotgun", random(-1,1), 0, 0, -12, 0, random(-1,1))
        PI2G A 0 A_PlaySound("pfire", 1)
		PI2G A 0 A_ZoomFactor(0.98)
		PI2G A 0 A_FireCustomMissile("YellowFlareSpawn",0,0,0,0)
		PI2G B 1 BRIGHT A_FireBullets (4, 2, -1, 17, "WeakPuff", FBF_NORANDOM)
		PI2G A 0 A_ZoomFactor(1.0)
		RIFF A 0 A_FireCustomMissile("DecorativeTracer", 1, 0, 4, 1)
		
		PI2G A 0 A_FireCustomMissile("PistolCaseSpawn",5,0,20,-4)
		PI2G C 1
		PI2G D 1
		PI2G D 0 A_TakeInventory("BDDualPistolAmmo", 1)//Removes 1 ammo from magazine
		PI2G D 0 A_TakeInventory("BDPistolAmmo", 1)//Remove the fake ammo
		PI2G E 0 A_JumpIfInventory("BDPistolAmmo", 1, 2)//sliding frame
		PI2G D 0
		PI2G "#" 1
		PI2G "#" 0
		PI2G "#" 0 A_JumpIfInventory("BDDualPistolAmmo", 1, 3)//Checks if there is ammo inside the gun
		PI2G "#" 0 //A_GiveInventory("Reloading", 1)//Couldn't find any ammo. Reload
		PI2G "#" 0 A_JumpIfInventory("BDPistolAmmo", 1, 1)//Checks if there is ammo inside the right Rifle
		Goto DryFire2//Couldn't find any ammo. Don't fire.
		//PI2F C 2
		PI2G "#" 2 A_WeaponReady(WRF_NOBOB)
		//PI2G "#" 0 A_Refire
		TNT1 A 0 A_JumpIfInventory("FiredSecondary", 1, "FireRightGun")		
		Goto Flash

		DryFire2:
	    //PI2G E 1 A_PlaySound("DRYFIRE", 1)
		//PI2G EEEEEEEEEE 1 A_JumpIfInventory("StopDualWield", 1, "LightDone")
		PI2G D 1
		Goto Flash
		
	Reload:
		TNT1 A 0 A_JumpIfInventory("BDDualPistolAmmo", 1, "Reload2")
	    TNT1 A 0 A_SetCrosshair(41)
	    PI2G E 1 //Always leave one free line before the reload animation to prevent bugs
		TNT1 A 0 A_TakeInventory("Reloading")//Always put this to make sure that the game understand that you already are reloading your weapon, and calling this state again is not necessary
		TNT1 A 0 A_JumpIfInventory("BDDualPistolAmmo", 32, "ReadytoFire")//Checks if the weapon is not fully reloaded, if yes, cancel reload.
		TNT1 A 0 A_PlaySound("DRYFIRE", 1)
		TNT1 A 0 A_JumpIfInventory("Clip1", 1, 1)//Checks if you have spare ammo
		Goto DryFire//Identified that you have no spare ammo. Get back to Ready animation
		TNT1 A 0 A_GiveInventory("StopDualWield", 1)

        
	Refill:	
	    TNT1 A 0
		TNT1 A 0 A_JumpIfInventory("Clip1", 1, 1)//Check if you have spare ammo again. This line is necessary in case you don't have enough ammo to fill an entire clip.
		Goto FinishReload//Gun is fully loaded. Go to finish animation
	    TNT1 A 0 A_TakeInventorY("Clip1", 1)//Removes one spare bullet
		TNT1 A 0 A_GiveInventory("BDDualPistolAmmo", 1)//Puts one bullet inside the clip
		TNT1 A 0 A_JumpIfInventory("BDDualPistolAmmo", 30, "FinishReload")//Checks if weapons is full
		Loop
		
	 FinishReload:	//Weapon is fully loaded. Time to play the reloading animation.
		TNT1 A 0
		PI2S DCBA 1
		TNT1 A 0 A_JumpIfInventory("LeftPistolAmmo", 16, "FinishReloadRight")
		TNT1 A 0 A_JumpIfInventory("BDPistolAmmo", 16, "FinishReloadLeft")
		TNT1 A 0 A_GiveInventory("LeftPistolAmmo", 15)
		TNT1 A 0 A_GiveInventory("BDPistolAmmo", 15)
		TNT1 A 5
		TNT1 A 0 A_PlaySound("RELOAD", 1)//reload sound
		TNT1 A 0 A_JumpIfInventory("HasUnloaded", 1, 2)
		TNT1 A 0 A_FireCustomMissile("EmptyClipSpawn",185,0,8,-4)
		BLER ZYXWWABCDE 1
        BLER FFFFFFFF 1
		BLER F 0 A_PlaySound("prel")
		BLER GGHIJ 1
		BLER KLMNOQP 1
		TNT1 A 10
		TNT1 A 0 A_PlaySound("RELOAD", 1)//reload sound
		TNT1 A 0 A_JumpIfInventory("HasUnloaded", 1, 2)
		TNT1 A 0 A_FireCustomMissile("EmptyClipSpawn",-5,0,8,-4)
		BRER ZYXWWABCDE 1
        BRER FFFFFFFF 1
		BRER F 0 A_PlaySound("prel")
		BRER GGHIJ 1
		BRER KLMNOQP 1
		TNT1 A 0 A_TakeInventory("StopDualWield", 1)
		TNT1 A 0 A_TakeInventory("FiredPrimary", 1)
		TNT1 A 0 A_TakeInventory("FiredSecondary", 1)
		TNT1 A 5
		TNT1 A 0 A_TakeInventory("Reloading")//Always put this to make sure that the game understand that you already are reloading your weapon, and calling this state again is not necessary
		TNT1 A 0 A_GunFlash
		TNT1 A 0 A_Takeinventory("HasUnloaded",1)
		Goto ReadyToFire
		
		
	FinishReloadS:	//Weapon is fully loaded. Time to play the reloading animation.
		TNT1 A 0
		TNT1 A 0 A_JumpIfInventory("LeftPistolAmmo", 16, "FinishReloadRight")
		TNT1 A 0 A_JumpIfInventory("BDPistolAmmo", 16, "FinishReloadLeft")
		TNT1 A 0 A_GiveInventory("LeftPistolAmmo", 15)
		TNT1 A 0 A_GiveInventory("BDPistolAmmo", 15)
		PI2S DCBA 1
		TNT1 A 5
		TNT1 A 0 A_PlaySound("RELOAD", 1)//reload sound
		TNT1 A 0 A_JumpIfInventory("HasUnloaded", 1, 2)
		TNT1 A 0 A_FireCustomMissile("EmptyClipSpawn",185,0,8,-4)
		R2MR ABCDDDDDDEFGHIIJJKLMNO 1
		TNT1 A 10
		TNT1 A 0 A_PlaySound("RELOAD", 1)//reload sound
		TNT1 A 0 A_JumpIfInventory("HasUnloaded", 1, 2)
		TNT1 A 0 A_FireCustomMissile("EmptyClipSpawn",-5,0,8,-4)
		R2ML ABCDDDDDDEFGHIIJJKLMNO 1
		TNT1 A 0 A_TakeInventory("StopDualWield", 1)
		TNT1 A 0 A_TakeInventory("FiredPrimary", 1)
		TNT1 A 0 A_TakeInventory("FiredSecondary", 1)
		TNT1 A 5
		PI2S ABCD 1
		TNT1 A 0 A_TakeInventory("Reloading")//Always put this to make sure that the game understand that you already are reloading your weapon, and calling this state again is not necessary
		TNT1 A 0 A_GunFlash
		TNT1 A 0 A_Takeinventory("HasUnloaded",1)
		Goto Ready
		
		
     FinishReloadP:	//Weapon is fully loaded. Time to play the reloading animation.
		TNT1 A 0
		TNT1 A 0 A_JumpIfInventory("LeftPistolAmmo", 16, "FinishReloadRight")
		TNT1 A 0 A_JumpIfInventory("BDPistolAmmo", 16, "FinishReloadLeft")
		TNT1 A 0 A_GiveInventory("LeftPistolAmmo", 15)
		TNT1 A 0 A_GiveInventory("BDPistolAmmo", 15)
		P2SS FEDCBA 1
		TNT1 A 5
		TNT1 A 0 A_PlaySound("RELOAD", 1)//reload sound
		TNT1 A 0 A_JumpIfInventory("HasUnloaded", 1, 2)
		TNT1 A 0 A_FireCustomMissile("EmptyClipSpawn",185,0,8,-4)
		P2RR ABCDDDDDDEFGHIIJJKLMNO 1
		TNT1 A 10
		TNT1 A 0 A_PlaySound("RELOAD", 1)//reload sound
		TNT1 A 0 A_JumpIfInventory("HasUnloaded", 1, 2)
		TNT1 A 0 A_FireCustomMissile("EmptyClipSpawn",-5,0,8,-4)
		P2RL ABCDDDDDDEFGHIIJJKLMNO 1
		TNT1 A 0 A_TakeInventory("StopDualWield", 1)
		TNT1 A 0 A_TakeInventory("FiredPrimary", 1)
		TNT1 A 0 A_TakeInventory("FiredSecondary", 1)
		TNT1 A 5
		P2SS ABCDEF 1
		TNT1 A 0 A_TakeInventory("Reloading")//Always put this to make sure that the game understand that you already are reloading your weapon, and calling this state again is not necessary
		TNT1 A 0 A_GunFlash
		TNT1 A 0 A_Takeinventory("HasUnloaded",1)
		Goto ReadyToFire
		
		//Reload 2 is for manual reload, leaves one more bullet inside the gun.
		
	Reload2:
	    TNT1 A 0 A_SetCrosshair(41)
	    PI2G I 0 A_JumpIfInventory("LeftPistolAmmo", 1, 2)//sliding frame
		PI2G H 0
		PI2G "#" 1 //Always leave one free line before the reload animation to prevent bugs
		TNT1 A 0 A_TakeInventory("Reloading")//Always put this to make sure that the game understand that you already are reloading your weapon, and calling this state again is not necessary
		TNT1 A 0 A_JumpIfInventory("BDDualPistolAmmo", 32, "ReadytoFire")//Checks if the weapon is not fully reloaded, if yes, cancel reload.
		TNT1 A 0 A_JumpIfInventory("Clip1", 1, 1)//Checks if you have spare ammo
		Goto ReadyToFire//The game identified that you have no spare ammo. Get back to Ready animation
		TNT1 A 0 A_GiveInventory("StopDualWield", 1)
        
	Refill2:	
	    TNT1 A 0
		TNT1 A 0 A_JumpIfInventory("Clip1", 1, 1)//Check if you have spare ammo again. This line is necessary in case you don't have enough ammo to fill an entire clip.
		Goto FinishReloadLeft
		TNT1 A 0 A_TakeInventorY("Clip1", 1)//Removes one spare bullet
		TNT1 A 0 A_GiveInventory("BDDualPistolAmmo", 1)//Puts one bullet inside the clip
		TNT1 A 0 A_JumpIfInventory("LeftPistolAmmo", 1, 2) //CHeck which gun is not empty, as Reload2 is the case for BDDualPistolAmmo >= 1
		TNT1 A 0 A_JumpIfInventory("BDDualPistolAmmo", 31, "FinishReloadLeft")
		TNT1 A 0 A_JumpIfInventory("BDPistolAmmo", 1, 2) //CHeck which gun is not empty, as Reload2 is the case for BDDualPistolAmmo >= 1
		TNT1 A 0 A_JumpIfInventory("BDDualPistolAmmo", 31, "FinishReloadLeft")
		TNT1 A 0 A_JumpIfInventory("BDDualPistolAmmo", 32, "FinishReloadLeft")//Checks if weapons is full
		Loop
		
		
		
	
	FinishReloadLeft:	
		TNT1 A 0 A_JumpIfInventory("LeftPistolAmmo", 16, "FinishReloadRight")
		TNT1 A 0 A_JumpIfInventory("LeftPistolAmmo", 1, "FinishReloadLeftNotEmpty")
		TNT1 A 0 A_GiveInventory("LeftPistolAmmo", 15)
		TNT1 A 5
		TNT1 A 0 A_PlaySound("RELOAD", 1)//reload sound
		TNT1 A 0 A_JumpIfInventory("HasUnloaded", 1, 2)
		TNT1 A 0 A_FireCustomMissile("EmptyClipSpawn",185,0,8,-4)
		BLER ZYXWWABCDE 1
        BLER FFFFFFFF 1
		BLER F 0 A_PlaySound("prel")
		BLER GGHIJ 1
		BLER KLMNOQP 1
		TNT1 A 0 A_TakeInventory("FiredPrimary", 1)
		TNT1 A 0 A_TakeInventory("FiredSecondary", 1)
		TNT1 A 5
		TNT1 A 0 A_TakeInventory("Reloading")//Always put this to make sure that the game understand that you already are reloading your weapon, and calling this state again is not necessary
		TNT1 A 0 A_Takeinventory("HasUnloaded",1)
		TNT1 A 0 A_JumpIfInventory("BDPistolAmmo", 16, 1)
		Goto FinishReloadRight
		TNT1 A 0 A_TakeInventory("StopDualWield",1)
		TNT1 A 0 A_GunFlash
		Goto ReadyToFire
		
	FinishReloadLeftNotEmpty:
		TNT1 A 0 A_GiveInventory("LeftPistolAmmo", 16)
		TNT1 A 5
		TNT1 A 0 A_PlaySound("RELOAD", 1)//reload sound
		TNT1 A 0 A_JumpIfInventory("HasUnloaded", 1, 2)
		BL2R ABCDEFFFFFFFFFGHIJKL 1
		BLER MNOP 2		
		TNT1 A 0 A_TakeInventory("FiredPrimary", 1)
		TNT1 A 0 A_TakeInventory("FiredSecondary", 1)
		TNT1 A 5
		TNT1 A 0 A_TakeInventory("Reloading")//Always put this to make sure that the game understand that you already are reloading your weapon, and calling this state again is not necessary
		TNT1 A 0 A_Takeinventory("HasUnloaded",1)
		TNT1 A 0 A_JumpIfInventory("BDPistolAmmo", 16, 1)
		Goto FinishReloadRight
		TNT1 A 0 A_TakeInventory("StopDualWield",1)
		TNT1 A 0 A_GunFlash
		Goto ReadyToFire
		
	FinishReloadRight:
		TNT1 A 0 A_JumpIfInventory("BDPistolAmmo", 1, "FinishReloadRightNotEmpty")
		TNT1 A 0 A_GiveInventory("BDPistolAmmo", 15)
		TNT1 A 5
		TNT1 A 0 A_PlaySound("RELOAD", 1)//reload sound
		TNT1 A 0 A_JumpIfInventory("HasUnloaded", 1, 2)
		TNT1 A 0 A_FireCustomMissile("EmptyClipSpawn",-5,0,8,-4)
		BRER ZYXWWABCDE 1
        BRER FFFFFFFF 1
		BRER F 0 A_PlaySound("prel")
		BRER GGHIJ 1
		BRER KLMNOQP 1
		TNT1 A 0 A_TakeInventory("StopDualWield", 1)
		TNT1 A 0 A_TakeInventory("FiredPrimary", 1)
		TNT1 A 0 A_TakeInventory("FiredSecondary", 1)
		TNT1 A 5
		TNT1 A 0 A_TakeInventory("Reloading")
		TNT1 A 0 A_GunFlash
		TNT1 A 0 A_Takeinventory("HasUnloaded",1)
		Goto ReadyToFire
		
	FinishReloadRightNotEmpty:
		TNT1 A 0 A_GiveInventory("BDPistolAmmo", 16)
		TNT1 A 5
		TNT1 A 0 A_PlaySound("RELOAD", 1)
		TNT1 A 0 A_JumpIfInventory("HasUnloaded", 1, 2)
		BR2R ABCDEFFFFFFFFFGHIJKL 1
		BRER MNOP 2
		TNT1 A 0 A_TakeInventory("StopDualWield", 1)
		TNT1 A 0 A_TakeInventory("FiredPrimary", 1)
		TNT1 A 0 A_TakeInventory("FiredSecondary", 1)
		TNT1 A 5
		TNT1 A 0 A_TakeInventory("Reloading")
		TNT1 A 0 A_GunFlash
		TNT1 A 0 A_Takeinventory("HasUnloaded",1)
		Goto ReadyToFire
		
		TossGrenade:
		PI2S DCBA 1
		TNT1 A 0 A_SetCrosshair(41)
		WTFL A 0 A_JumpIfInventory("IsPaladin",1,"PallyGrenadeToss")
		TNT1 A 0 A_TakeInventory("TossGrenade", 1)
		TNT1 A 0 A_JumpIfInventory("GrenadeAmmo", 1, 3)
		TNT1 A 0 A_Print("No Grenades Left.")
		Goto SelectAnimation
		GRTH ABCD 1
		TNT1 A 0 A_GiveInventory("FiredGrenade", 1)
		TNT1 A 0 A_Giveinventory("Punching",1)
		TNT1 A 0 A_Giveinventory("GoSpecial",1)
		TNT1 A 0 A_PLaySound ("GRNPIN")
		GRTH EEFG 1
		TNT1 A 0 A_PLaySound ("GRNTOSS")
		GRTH HI 1
		TNT1 A 0 A_TakeInventory("GrenadeAmmo", 1)
		TNT1 A 0 A_FireCustomMissile("HandGrenade", random(-2,2), 0, 0, 0, 0, 0)
	    TNT1 A 0 A_TakeInventory("FiredGrenade", 1)
		GRTH JKLM 1
		TNT1 A 1
		TNT1 A 0 A_TakeInventory("TossGrenade", 1)
		Goto SelectAnimation
	PallyGrenadeToss:
		TNT1 A 0 A_TakeInventory("TossGrenade", 1)
		TNT1 A 0 A_JumpIfInventory("GrenadeAmmo", 1, 1)
		Goto PallyNoGrenade
		TNT1 A 0 A_GiveInventory("FiredGrenade", 1)
		TNT1 A 0 A_PLaySound ("GRNPIN")
		TNT1 A 4 //wait a moment
		WTFL ABCDEF 1
		TNT1 A 0 A_PLaySound ("GRNTOSS")
		TNT1 A 0 A_TakeInventory("GrenadeAmmo", 1)
		TNT1 A 0 A_FireCustomMissile("HandGrenade", random(-2,2), 0, 0, 0, 0, 0)
	    TNT1 A 0 A_TakeInventory("FiredGrenade", 1)
		WTFL GHIJKL 1
		Goto SelectAnimation
	PallyNoGrenade:
		TNT1 A 0 A_Print("No Grenades Left.")
		Goto SelectAnimation
		
		
	Fire2:
		TNT1 A 0
		RIFF A 0 A_FireCustomMissile("DistantFireSoundShotgun", random(-1,1), 0, 0, -12, 0, random(-1,1))
        PI2G A 0 A_PlaySound("pfire", 1)
		PI2G A 0 A_PlaySound("pfire", 2)
		PI2G A 0 A_ZoomFactor(0.98)
		PI2G A 0 A_FireCustomMissile("YellowFlareSpawn",0,0,0,0)
		PI2F A 1 BRIGHT A_FireBullets (6, 6, 2, 17, "WeakPuff", FBF_NORANDOM)
		PI2G A 0 A_ZoomFactor(1.0)
		TNT1 A 0 A_SetPitch(pitch-1)
        RIFF A 0 A_FireCustomMissile("DecorativeTracer", -1, 0, -4, -1)
		PI2G A 0 A_Takeinventory("BDPistolAmmo",1)
		PI2G A 0 A_Takeinventory("BDDualPistolAmmo",2)
		PI2G A 0 A_FireCustomMissile("PistolCaseSpawn",5,0,10,-4)

		PI2G A 0 A_JumpIfInventory("BDPistolAmmo",1,2)//Checks if single gun is not depleted
        Goto NoAmmoOnSecondGun
		TNT1 AA 0
		PI2G A 0 A_JumpIfInventory("BDDualPistolAmmo",1,1)
        Goto NoAmmo
		
		RIFF A 0 A_FireCustomMissile("DistantFireSoundShotgun", random(-1,1), 0, 0, -12, 0, random(-1,1))
        PI2G A 0 A_PlaySound("pfire", 1)
		PI2G A 0 A_PlaySound("pfire", 2)
		PI2G A 0 A_ZoomFactor(0.98)
		PI2G A 0 A_FireCustomMissile("YellowFlareSpawn",0,0,0,0)
		PI2F D 1 BRIGHT A_FireBullets (6, 6, 2, 17, "WeakPuff", FBF_NORANDOM)
		PI2G A 0 A_ZoomFactor(1.0)
		TNT1 A 0 A_SetPitch(pitch-1)
        RIFF A 0 A_FireCustomMissile("DecorativeTracer", 1, 0, 4, -1)
		PI2G A 0 A_Takeinventory("BDPistolAmmo",1)
		PI2G A 0 A_Takeinventory("BDDualPistolAmmo",2)
		PI2G A 0 A_FireCustomMissile("PistolCaseSpawn",5,0,-10,-4)
		
		
		
		RIFF A 0 A_FireCustomMissile("DistantFireSoundShotgun", random(-1,1), 0, 0, -12, 0, random(-1,1))
        PI2G A 0 A_PlaySound("pfire", 1)
		PI2G A 0 A_PlaySound("pfire", 2)
		PI2G A 0 A_ZoomFactor(0.98)
		TNT1 A 0 A_SetPitch(pitch-3)
		PI2G A 0 A_FireCustomMissile("YellowFlareSpawn",0,0,0,0)
		PI2F A 1 BRIGHT A_FireBullets (6, 6, 2, 17, "WeakPuff", FBF_NORANDOM)
		PI2G A 0 A_ZoomFactor(1.0)
        RIFF A 0 A_FireCustomMissile("DecorativeTracer", -1, 0, -4, -1)
		PI2G A 0 A_Takeinventory("BDPistolAmmo",1)
		PI2G A 0 A_Takeinventory("BDDualPistolAmmo",2)
		PI2G A 0 A_FireCustomMissile("PistolCaseSpawn",5,0,10,-4)
		
		
		PI2F IJK 1
		PI2G A 1 A_WeaponReady(WRF_NOBOB) 
		PI2G A 6 A_WeaponReady(WRF_NOBOB)
		Goto Ready		
		
	NoAmmo:
		RIFG A 0
		RIFG A 0 A_ZoomFactor(1.0)
		RIFG A 0 A_Takeinventory("Zoomed",1)
		RIFG A 0 A_Takeinventory("ADSmode",1)
		RIFG A 0 A_JumpIfInventory("TurboReload",1,"TurboReload")
		TNT1 A 0 A_PlaySound("weapons/empty", 4)
		NoAmmo2:
		RIFG A 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
	    RIFG A 0 A_JumpIfInventory("Taunting",1,"Taunt")
		RIFG A 0 A_JumpIfInventory("Salute1", 1, "Salute")
		RIFG A 0 A_JumpIfInventory("Salute2", 1, "Salute")
		RIFG A 0 A_JumpIfInventory("Kicking",1,"DoKick")
		PI2G A 5 A_WeaponReady(WRF_ALLOWRELOAD | WRF_NOFIRE)
		RIFG A 0 A_JumpIfInventory("Reloading",1,"Reload")
		RIFG A 0 A_JumpIfInventory("TurboReload",1,"TurboReload")
		TNT1 A 0 A_JumpIfInventory("NoAutoReload", 1, "NoAmmo2")
		RIFG A 0 A_JumpIfInventory("Clip1",1,"Reload")
		RIFG A 0 A_JumpIfInventory("FiredPrimary",1,"NoAmmo2")
		Goto Ready3
	
    OldReload:
		PI2G A 1 A_WeaponReady
		PI2G A 0 A_Takeinventory("Reloading",1)
		PI2G A 0 A_Takeinventory("ADSmode",1)
		PI2G A 0 A_JumpIfInventory("BDDualPistolAmmo",17,"Ready")

        PI2G A 0 A_JumpIfInventory("Clip1",1,3)
        Goto NoAmmo
        TNT1 AAA 0
		PI2G A 0 A_Takeinventory("Zoomed",1)
        PI2G A 0 A_ZoomFactor(1.0)
		PI2G A 0 A_GiveInventory ("Pumping", 1)
		PI2G A 0 A_Takeinventory("Reloading",1)
		PI2G A 0 A_JumpIfInventory("TurboReload",1,"TurboReload")
		
		PI2G A 0 A_PlaySound("reload")
		PI2S DCBA 1
		TNT1 A 2
		PI2G A 0 A_JumpIfInventory("HasUnloaded", 1, 2)
		RIFR C 0 A_FireCustomMissile("EmptyClipSpawn",-5,0,8,-4)
        PISR BCDEFFFFF 1 
		PI2G A 0 A_PlaySound("prel")
        PISR GHIIJKLMNNNOPQR 1
		TNT1 A 2
		
		PI2G A 0 A_JumpIfInventory("HasUnloaded", 1, 2)
		RIFR C 0 A_FireCustomMissile("EmptyClipSpawn",-5,0,8,-4)
		PI2R BCDEFFFFF 1 
		PI2G A 0 A_PlaySound("prel")
        PI2R GHIIJKLMNNNOPQR 1
		TNT1 A 2
		PI2S ABCD 1
		PI2G A 0 A_JumpIfInventory("BDDualPistolAmmo",1,"InsertBullets2")//15+1 effect
		
	TurboReload:
		PI2G A 0 A_Takeinventory("HasUnloaded",1)
        PIS2 BA 0
        Goto InsertBullets
		
	InsertBullets:
		TNT1 AAAA 0
		PI2G A 0 A_JumpIfInventory("BDDualPistolAmmo",15,15)
		PI2G A 0 A_JumpIfInventory("Clip1",1,3)
		Goto Ready
        TNT1 AAAAAA 0
		PI2G A 0 A_Giveinventory("BDDualPistolAmmo",1)
		PI2G A 0 A_Giveinventory("BDPistolAmmo",1)
		PI2G A 0 A_Takeinventory("Clip1",1)
		Goto InsertBullets
		
		TNT1 AAAAAAAAAA 0
		PI2G A 0 A_Takeinventory("Reloading",1)
		
		PI2G A 0 A_Refire
        Goto Ready
		TNT1 AAAA 0
		PI2G A 0 A_Takeinventory("Reloading",1)
		
		PI2G A 0 A_Refire
        Goto Ready
		
	InsertBullets2:
		TNT1 AAAA 0
		PI2G A 0 A_JumpIfInventory("BDDualPistolAmmo",17,15)
		PI2G A 0 A_JumpIfInventory("Clip1",1,3)
		Goto Ready
        TNT1 AAAAAA 0
		PI2G A 0 A_Giveinventory("BDDualPistolAmmo",1)
		PI2G A 0 A_Giveinventory("BDPistolAmmo",1)
		PI2G A 0 A_Takeinventory("Clip1",1)
		Goto InsertBullets2
		
		TNT1 AAAAAAAAAA 0
		PI2G A 0 A_Takeinventory("Reloading",1)
		PI2G A 0 A_Refire
        Goto Ready
		TNT1 AAAA 0
		PI2G A 0 A_Takeinventory("Reloading",1)
		
		PI2G A 0 A_Refire
        Goto Ready	
		
	Unload:
		PI2G A 1 A_WeaponReady
		PI2G A 0 A_Takeinventory("Unloading",1)
		PI2G A 0 A_Takeinventory("ADSmode",1)
		PI2G A 0 A_JumpIfInventory("BDPistolAmmo",1,3)
        Goto NoAmmo
        TNT1 AAA 0
		PI2G A 0 A_Takeinventory("Zoomed",1)
        PI2G A 0 A_ZoomFactor(1.0)
		PI2G A 0 A_GiveInventory ("Pumping", 1)
		PI2G A 0 A_Takeinventory("Reloading",1)
        PISR RQPONNNMLKJIIHG 1
		PI2G A 0 A_PlaySound("prel")
		PISR FFFEDCBA 1
		
		PI2R RQPONNNMLKJIIHG 1
		PI2G A 0 A_PlaySound("prel")
		PI2R FFFEDCBA 1
		PI2G A 0 A_Giveinventory("HasUnloaded",1)
		PI2G A 0 A_JumpIfInventory("BDPistolAmmo",1,"RemoveBullets")

	RemoveBullets:
		TNT1 AAAA 0
		PI2G A 0 A_JumpIfInventory("BDDualPistolAmmo",1,3)
		Goto Ready
        TNT1 AAAAAA 0
		PI2G A 0 A_Takeinventory("BDPistolAmmo",1)
		PI2G A 0 A_Takeinventory("BDDualPistolAmmo",1)
		PI2G A 0 A_Giveinventory("Clip1",1)
		Goto RemoveBullets
		
		TNT1 AAAAAAAAAA 0
		PI2G A 0 A_Takeinventory("Reloading",1)
		
		PI2G A 0 A_Refire
        Goto Ready
		TNT1 AAAA 0
		PI2G A 0 A_Takeinventory("Reloading",1)
		
		PI2G A 0 A_Refire
        Goto Ready
	
 	Spawn:
		RIFL A -1
		Stop
		
	Steady:
		TNT1 A 1
		Goto Ready	
	}
}

ACTOR LeftPistolAmmo:  Ammo
{
   Inventory.Amount 0
   Inventory.MaxAmount 16 //Your weapon's magazine ammo limit. Always leave one more bullet, so you can do the 12+1 effect.
   Ammo.BackpackAmount 0
   Ammo.BackpackMaxAmount 16
   Inventory.Icon "PISTG0"
}